from flask import Flask, render_template, request
app = Flask(__name__)

#基本用法
@app.route('/')
def index():
    LIST = [1, 2, 3, 4, 5]
    DETAILS = {
        "name": "张三",
        "age": "10",
        "gender": "女",
        "score": '100'
    }
    return render_template('index.html',details=DETAILS,list=LIST)

#filter
@app.template_filter() #创建自定义过滤器
def upperWord(value):
    return value[0].upper() + value[1:]
@app.route('/filter/<name>')  # 用 <int:score> 限定为整数类型
def filterData(name):
    return render_template('filter.html', name=name)

#条件语句 if-elif-else
@app.route('/queryScore/<int:score>')
def queryScore(score):
    return render_template('if-elif-else.html',score=score)


#循环语句
@app.route('/loop')
def loop():
    cities = ['上海', '北京', '广州', '深圳', '大连', '成都', '重庆', '武汉', '新疆']
    return render_template('loop.html',cities=cities)



if __name__ == '__main__':
    app.run(debug=True)